package com.wealth.bbs.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.wealth.bbs.entity.Board;
import com.wealth.bbs.service.IBoardService;
import com.wealth.page.entity.Ad;
import com.wealth.page.enums.AdTypeEnum;
import com.wealth.page.service.IADService;
import com.wealth.system.web.controller.BaseController;

import iaas.annotation.Login;
import iaas.enums.StatusEnum;

/**
 * 论坛
 * @author chan
 *
 */
@Controller
@RequestMapping(value = "/bbs")
public class BBsController extends BaseController {
	
	Logger logger = Logger.getLogger(BBsController.class);

	@Autowired
	private IBoardService boardService;
	@Autowired
	private IADService adService;
	
	/**
	 * 首页
	 */
	@RequestMapping
	@Login
	public String index(Model model,HttpServletRequest request) {
		try{
			//TODO
			//板块分类
			List<Board> boardList= boardService.getBoardByCorpIdAndStatus(corpid, StatusEnum.NORMAL.getValue());
			
			//广告列表
			List<Ad> adList= adService.getAdByCorpIdAndTypeAndStatus(corpid, AdTypeEnum.BBS.getValue(), StatusEnum.NORMAL.getValue());
			
			model.addAttribute("boardList", boardList);
			model.addAttribute("adList", adList);
			return "bbs/index";
		}catch(Exception e){
			return "system/500";
		}	
	}
	
}
